<?php
/**
 *初始化组件类 
 */
namespace core;
class init {
    public $Parts = array();//需加载的部件数组
    public $Libs = array();//需加载的类库数组
    protected $config;//项目配置
    public function __construct($config = null) {
       $this->config = $config;
       $this->loadLib();
       $this->loadPart();
    }
    /**
     *加载部件方法 
     */
    public function loadPart(){
        $Parts = array();
         foreach ($this->Parts as $value) {
            $namespace = explode("\\", get_called_class());
            array_pop($namespace);
            $class = implode("\\", $namespace) . "\\" . $value;
            if(isset($this->Confs[$value]) && $this->Confs[$value] == true){
                $config = $this->config;
                $this->$value = new $class($config);
            }else{
                $this->$value = new $class();
            }
        }
    }
    /**
     *加载类库方法 
     */
    public function loadLib() {
        foreach ($this->Libs as $value) {
            switch ($value) {
                case "smarty":
                    require_once FRM_PATH.'/libraries/smarty/Smarty.class.php';
                    break;
                default:
                    break;
            }
        }
    }
    public function __set($name,$value){
        $this->$name = $value;
    }
    public function __get($name){
        return $this->$name;
    }

}

?>
